﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using ITAP.ShprossesBuilder.Properties;
using ITAP.Core.Modelling;

namespace ITAP.ShprossesBuilder.Operations
{
    public class OperationZoomAuto : IOperation
    {
        #region IOperation Members

        public string Name
        {
            get { return "Авторазмер"; }
        }

        public OperationGroup OperationGroup
        {
            get { return OperationGroup.Other; }
        }

        public System.Drawing.Image Thumbnail
        {
            get { return Resources.Auto.ToBitmap(); }
        }

        public void Execute(ModelControl modelControl)
        {
            if (modelControl.ModelContainer.InnerComponents.Count == 0)
                return;

            RectangleF cameraCenter = modelControl.ModelContainer.BoundingBox;
            modelControl.UseAutoScale = true;
            modelControl.Camera = new ModelPoint(cameraCenter.Width / 2, cameraCenter.Height / 2);
            modelControl.Invalidate();

        }

        public bool CanUndo
        {
            get { return false; }
        }

        #endregion
    }
}
